{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# PyTorch：定义自己的自动求导函数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "在底层，每一个原始的自动求导运算实际上是两个在Tensor上运行的函数。其中，**forward**函数计算从输入Tensors获得的输出Tensors。而**backward**函数接收输出Tensors对于某个标量值的梯度，并且计算输入Tensors相对于该相同标量值的梯度。 \n",
    "\n",
    "在PyTorch中，我们可以很容易地通过定义`torch.autograd.Function`的子类并实现`forward`和`backward`函数，来定义自己的自动求导运算。之后我们就可以使用这个新的自动梯度运算符了。然后，我们可以通过构造一个实例并像调用函数一样，传入包含输入数据的tensor调用它，这样来使用新的自动求导运算。\n",
    "\n",
    "这个例子中，我们自定义一个自动求导函数来展示ReLU的非线性。并用它实现我们的两层网络"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 28410422.0\n",
      "1 23503384.0\n",
      "2 24120684.0\n",
      "3 26386672.0\n",
      "4 27314008.0\n",
      "5 24231912.0\n",
      "6 17958576.0\n",
      "7 11102356.0\n",
      "8 6172408.5\n",
      "9 3319347.0\n",
      "10 1876437.375\n",
      "11 1162245.875\n",
      "12 798493.5625\n",
      "13 597297.25\n",
      "14 474415.65625\n",
      "15 391307.59375\n",
      "16 330292.875\n",
      "17 282776.0\n",
      "18 244352.4375\n",
      "19 212551.0\n",
      "20 185790.875\n",
      "21 163028.109375\n",
      "22 143527.078125\n",
      "23 126736.125\n",
      "24 112204.875\n",
      "25 99586.0625\n",
      "26 88587.2890625\n",
      "27 78970.0\n",
      "28 70542.40625\n",
      "29 63140.6171875\n",
      "30 56612.61328125\n",
      "31 50842.5625\n",
      "32 45734.25\n",
      "33 41198.7578125\n",
      "34 37166.75\n",
      "35 33573.1328125\n",
      "36 30365.576171875\n",
      "37 27499.107421875\n",
      "38 24933.4296875\n",
      "39 22634.890625\n",
      "40 20569.662109375\n",
      "41 18711.353515625\n",
      "42 17036.8046875\n",
      "43 15526.45703125\n",
      "44 14163.080078125\n",
      "45 12930.119140625\n",
      "46 11814.32421875\n",
      "47 10802.939453125\n",
      "48 9886.189453125\n",
      "49 9053.7724609375\n",
      "50 8297.2822265625\n",
      "51 7608.72509765625\n",
      "52 6981.86572265625\n",
      "53 6410.78076171875\n",
      "54 5890.9462890625\n",
      "55 5416.35546875\n",
      "56 4982.798828125\n",
      "57 4586.35400390625\n",
      "58 4223.77978515625\n",
      "59 3891.867919921875\n",
      "60 3587.977294921875\n",
      "61 3309.2255859375\n",
      "62 3053.63916015625\n",
      "63 2819.09716796875\n",
      "64 2603.7373046875\n",
      "65 2405.765625\n",
      "66 2223.7724609375\n",
      "67 2056.347900390625\n",
      "68 1902.234375\n",
      "69 1760.3837890625\n",
      "70 1629.6898193359375\n",
      "71 1509.2579345703125\n",
      "72 1398.28662109375\n",
      "73 1295.867431640625\n",
      "74 1201.355712890625\n",
      "75 1114.052734375\n",
      "76 1033.4393310546875\n",
      "77 958.9227294921875\n",
      "78 890.0482177734375\n",
      "79 826.35693359375\n",
      "80 767.4517211914062\n",
      "81 712.9520263671875\n",
      "82 662.492431640625\n",
      "83 615.7662353515625\n",
      "84 572.4993286132812\n",
      "85 532.3809204101562\n",
      "86 495.19354248046875\n",
      "87 460.7100524902344\n",
      "88 428.7293701171875\n",
      "89 399.06695556640625\n",
      "90 371.53106689453125\n",
      "91 345.9598388671875\n",
      "92 322.2213134765625\n",
      "93 300.1630859375\n",
      "94 279.6756591796875\n",
      "95 260.63818359375\n",
      "96 242.9359130859375\n",
      "97 226.48855590820312\n",
      "98 211.18829345703125\n",
      "99 196.95166015625\n",
      "100 183.7096405029297\n",
      "101 171.38389587402344\n",
      "102 159.91226196289062\n",
      "103 149.28411865234375\n",
      "104 139.38247680664062\n",
      "105 130.1586151123047\n",
      "106 121.56716918945312\n",
      "107 113.56037902832031\n",
      "108 106.09262084960938\n",
      "109 99.13337707519531\n",
      "110 92.64399719238281\n",
      "111 86.5908432006836\n",
      "112 80.94572448730469\n",
      "113 75.67575073242188\n",
      "114 70.76142883300781\n",
      "115 66.17451477050781\n",
      "116 61.892059326171875\n",
      "117 57.89387512207031\n",
      "118 54.160606384277344\n",
      "119 50.67465591430664\n",
      "120 47.416748046875\n",
      "121 44.37689208984375\n",
      "122 41.53478240966797\n",
      "123 38.87932586669922\n",
      "124 36.39892578125\n",
      "125 34.07865524291992\n",
      "126 31.911128997802734\n",
      "127 29.884374618530273\n",
      "128 27.9891414642334\n",
      "129 26.216007232666016\n",
      "130 24.558752059936523\n",
      "131 23.009212493896484\n",
      "132 21.559337615966797\n",
      "133 20.2025203704834\n",
      "134 18.933006286621094\n",
      "135 17.744464874267578\n",
      "136 16.632720947265625\n",
      "137 15.592419624328613\n",
      "138 14.617942810058594\n",
      "139 13.705780982971191\n",
      "140 12.851919174194336\n",
      "141 12.052352905273438\n",
      "142 11.303704261779785\n",
      "143 10.602217674255371\n",
      "144 9.945161819458008\n",
      "145 9.329813003540039\n",
      "146 8.753376007080078\n",
      "147 8.212624549865723\n",
      "148 7.706542015075684\n",
      "149 7.2320404052734375\n",
      "150 6.787666320800781\n",
      "151 6.370745658874512\n",
      "152 5.980212211608887\n",
      "153 5.614123821258545\n",
      "154 5.270718574523926\n",
      "155 4.948566436767578\n",
      "156 4.646498680114746\n",
      "157 4.363554000854492\n",
      "158 4.0978569984436035\n",
      "159 3.848881959915161\n",
      "160 3.6152749061584473\n",
      "161 3.3958287239074707\n",
      "162 3.190089702606201\n",
      "163 2.997304677963257\n",
      "164 2.8162593841552734\n",
      "165 2.6462535858154297\n",
      "166 2.486661911010742\n",
      "167 2.3370258808135986\n",
      "168 2.1963634490966797\n",
      "169 2.0643959045410156\n",
      "170 1.9405728578567505\n",
      "171 1.8243165016174316\n",
      "172 1.7151007652282715\n",
      "173 1.6126041412353516\n",
      "174 1.5162005424499512\n",
      "175 1.4258091449737549\n",
      "176 1.3408013582229614\n",
      "177 1.260951280593872\n",
      "178 1.1860013008117676\n",
      "179 1.1156229972839355\n",
      "180 1.0494662523269653\n",
      "181 0.9872617721557617\n",
      "182 0.9287808537483215\n",
      "183 0.8738675117492676\n",
      "184 0.8222478032112122\n",
      "185 0.7737525701522827\n",
      "186 0.7282744646072388\n",
      "187 0.685305118560791\n",
      "188 0.6449705362319946\n",
      "189 0.6071871519088745\n",
      "190 0.571499228477478\n",
      "191 0.5380487442016602\n",
      "192 0.5065485835075378\n",
      "193 0.4769226312637329\n",
      "194 0.44907671213150024\n",
      "195 0.4228886663913727\n",
      "196 0.39820724725723267\n",
      "197 0.37498021125793457\n",
      "198 0.35313355922698975\n",
      "199 0.3325989842414856\n",
      "200 0.3133089542388916\n",
      "201 0.2950977683067322\n",
      "202 0.277996301651001\n",
      "203 0.2619459629058838\n",
      "204 0.24679243564605713\n",
      "205 0.23254892230033875\n",
      "206 0.21914564073085785\n",
      "207 0.2065022587776184\n",
      "208 0.19459709525108337\n",
      "209 0.1834125816822052\n",
      "210 0.17284730076789856\n",
      "211 0.16289541125297546\n",
      "212 0.15354512631893158\n",
      "213 0.14477500319480896\n",
      "214 0.13652536273002625\n",
      "215 0.12872517108917236\n",
      "216 0.12138328701257706\n",
      "217 0.11444054543972015\n",
      "218 0.10791748762130737\n",
      "219 0.1017579436302185\n",
      "220 0.09596209973096848\n",
      "221 0.09051039069890976\n",
      "222 0.08538135886192322\n",
      "223 0.08052122592926025\n",
      "224 0.07595080137252808\n",
      "225 0.07165219634771347\n",
      "226 0.06759986281394958\n",
      "227 0.06380374729633331\n",
      "228 0.06018892675638199\n",
      "229 0.05680157616734505\n",
      "230 0.0536092147231102\n",
      "231 0.05059139430522919\n",
      "232 0.047759830951690674\n",
      "233 0.04506794363260269\n",
      "234 0.04254794120788574\n",
      "235 0.040162310004234314\n",
      "236 0.03791811317205429\n",
      "237 0.035795170813798904\n",
      "238 0.03379633277654648\n",
      "239 0.0318937785923481\n",
      "240 0.03012852929532528\n",
      "241 0.028445377945899963\n",
      "242 0.026850100606679916\n",
      "243 0.025377459824085236\n",
      "244 0.02397383376955986\n",
      "245 0.022645780816674232\n",
      "246 0.021399009972810745\n",
      "247 0.020210936665534973\n",
      "248 0.019091930240392685\n",
      "249 0.018046759068965912\n",
      "250 0.01705620065331459\n",
      "251 0.01610945351421833\n",
      "252 0.01522053498774767\n",
      "253 0.014388603158295155\n",
      "254 0.013602912425994873\n",
      "255 0.012863320298492908\n",
      "256 0.01216185837984085\n",
      "257 0.011508936993777752\n",
      "258 0.010890735313296318\n",
      "259 0.010311530902981758\n",
      "260 0.009747686795890331\n",
      "261 0.009228476323187351\n",
      "262 0.008736556395888329\n",
      "263 0.008269447833299637\n",
      "264 0.00783202238380909\n",
      "265 0.007417196873575449\n",
      "266 0.007026806939393282\n",
      "267 0.006655239034444094\n",
      "268 0.0063030170276761055\n",
      "269 0.005975652020424604\n",
      "270 0.005664409138262272\n",
      "271 0.005364415235817432\n",
      "272 0.00508895143866539\n",
      "273 0.004819122143089771\n",
      "274 0.004575546830892563\n",
      "275 0.00434450339525938\n",
      "276 0.004124830476939678\n",
      "277 0.003912446089088917\n",
      "278 0.003719146829098463\n",
      "279 0.003528730943799019\n",
      "280 0.003353819018229842\n",
      "281 0.0031863211188465357\n",
      "282 0.003029055427759886\n",
      "283 0.0028786498587578535\n",
      "284 0.0027368911541998386\n",
      "285 0.002604931592941284\n",
      "286 0.002480786759406328\n",
      "287 0.0023625169415026903\n",
      "288 0.002248641336336732\n",
      "289 0.0021439038682729006\n",
      "290 0.002040754770860076\n",
      "291 0.0019439748721197248\n",
      "292 0.001854330999776721\n",
      "293 0.0017686996143311262\n",
      "294 0.001690236502327025\n",
      "295 0.0016122650122269988\n",
      "296 0.0015406444435939193\n",
      "297 0.001472140196710825\n",
      "298 0.0014084584545344114\n",
      "299 0.0013470331905409694\n",
      "300 0.0012874092208221555\n",
      "301 0.001231800764799118\n",
      "302 0.0011808848939836025\n",
      "303 0.0011295764707028866\n",
      "304 0.0010822974145412445\n",
      "305 0.0010371359530836344\n",
      "306 0.0009964994387701154\n",
      "307 0.0009545501670800149\n",
      "308 0.0009162935893982649\n",
      "309 0.0008786015678197145\n",
      "310 0.0008426237618550658\n",
      "311 0.0008096569799818099\n",
      "312 0.0007789860246703029\n",
      "313 0.0007489296258427203\n",
      "314 0.0007201757980510592\n",
      "315 0.0006914841942489147\n",
      "316 0.0006659028003923595\n",
      "317 0.0006417362601496279\n",
      "318 0.0006163991056382656\n",
      "319 0.000592883094213903\n",
      "320 0.0005720591871067882\n",
      "321 0.0005512806819751859\n",
      "322 0.0005309212137944996\n",
      "323 0.0005119163542985916\n",
      "324 0.0004938396159559488\n",
      "325 0.00047618005191907287\n",
      "326 0.00046024139737710357\n",
      "327 0.00044463094673119485\n",
      "328 0.0004301682347431779\n",
      "329 0.0004151187895331532\n",
      "330 0.0004023040528409183\n",
      "331 0.0003877429408021271\n",
      "332 0.00037610650178976357\n",
      "333 0.0003641139483079314\n",
      "334 0.0003525771026033908\n",
      "335 0.0003414886014070362\n",
      "336 0.00033116189297288656\n",
      "337 0.00032045808620750904\n",
      "338 0.0003108568489551544\n",
      "339 0.00030127749778330326\n",
      "340 0.0002924822038039565\n",
      "341 0.00028326036408543587\n",
      "342 0.0002754181041382253\n",
      "343 0.0002671222318895161\n",
      "344 0.00026023341342806816\n",
      "345 0.00025273149367421865\n",
      "346 0.0002457651135046035\n",
      "347 0.0002391083398833871\n",
      "348 0.00023306350340135396\n",
      "349 0.0002268484968226403\n",
      "350 0.000220681686187163\n",
      "351 0.0002155194233637303\n",
      "352 0.0002092235372401774\n",
      "353 0.00020363181829452515\n",
      "354 0.00019782866002060473\n",
      "355 0.00019352980598341674\n",
      "356 0.00018829555483534932\n",
      "357 0.00018365937285125256\n",
      "358 0.00017888030561152846\n",
      "359 0.00017462843970861286\n",
      "360 0.00017040818056557328\n",
      "361 0.00016640726244077086\n",
      "362 0.00016244934522546828\n",
      "363 0.00015859969425946474\n",
      "364 0.0001551454479340464\n",
      "365 0.0001509910071035847\n",
      "366 0.00014772663416806608\n",
      "367 0.00014426014968194067\n",
      "368 0.00014102307613939047\n",
      "369 0.00013832160038873553\n",
      "370 0.00013475920422933996\n",
      "371 0.0001316502457484603\n",
      "372 0.00012896338012069464\n",
      "373 0.00012591898848768324\n",
      "374 0.00012376255472190678\n",
      "375 0.00012116106518078595\n",
      "376 0.00011841723608085886\n",
      "377 0.00011581268336158246\n",
      "378 0.00011409129365347326\n",
      "379 0.00011153105879202485\n",
      "380 0.00010910887795034796\n",
      "381 0.00010683244181564078\n",
      "382 0.00010461050987942144\n",
      "383 0.00010285489406669512\n",
      "384 0.00010089382703881711\n",
      "385 9.903984027914703e-05\n",
      "386 9.680898074293509e-05\n",
      "387 9.512461838312447e-05\n",
      "388 9.37648001126945e-05\n",
      "389 9.168988617602736e-05\n",
      "390 8.99890874279663e-05\n",
      "391 8.867843280313537e-05\n",
      "392 8.675281424075365e-05\n",
      "393 8.508918836014345e-05\n",
      "394 8.363578672287986e-05\n",
      "395 8.226196223404258e-05\n",
      "396 8.071102638496086e-05\n",
      "397 7.928428385639563e-05\n",
      "398 7.784189801895991e-05\n",
      "399 7.654681394342333e-05\n",
      "400 7.531495066359639e-05\n",
      "401 7.378082955256104e-05\n",
      "402 7.274233212228864e-05\n",
      "403 7.122513488866389e-05\n",
      "404 7.01864919392392e-05\n",
      "405 6.888787902425975e-05\n",
      "406 6.797804235247895e-05\n",
      "407 6.691726593999192e-05\n",
      "408 6.574959843419492e-05\n",
      "409 6.480971933342516e-05\n",
      "410 6.36622789897956e-05\n",
      "411 6.262306123971939e-05\n",
      "412 6.14859236520715e-05\n",
      "413 6.040218431735411e-05\n",
      "414 5.9699712437577546e-05\n",
      "415 5.861406680196524e-05\n",
      "416 5.770180723629892e-05\n",
      "417 5.6679989938857034e-05\n",
      "418 5.5918502766871825e-05\n",
      "419 5.503535066964105e-05\n",
      "420 5.442995097837411e-05\n",
      "421 5.341286305338144e-05\n",
      "422 5.260392572381534e-05\n",
      "423 5.1984356105094776e-05\n",
      "424 5.1374641770962626e-05\n",
      "425 5.0582297262735665e-05\n",
      "426 5.0122376705985516e-05\n",
      "427 4.940544022247195e-05\n",
      "428 4.849370816373266e-05\n",
      "429 4.802519833901897e-05\n",
      "430 4.746085323859006e-05\n",
      "431 4.669504414778203e-05\n",
      "432 4.621710104402155e-05\n",
      "433 4.5609667722601444e-05\n",
      "434 4.488652484724298e-05\n",
      "435 4.430652188602835e-05\n",
      "436 4.385682041174732e-05\n",
      "437 4.343572072684765e-05\n",
      "438 4.2771334847202525e-05\n",
      "439 4.233631625538692e-05\n",
      "440 4.151082976022735e-05\n",
      "441 4.1107661672867835e-05\n",
      "442 4.0414073737338185e-05\n",
      "443 3.989019023720175e-05\n",
      "444 3.952899714931846e-05\n",
      "445 3.9130685763666406e-05\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "446 3.858437412418425e-05\n",
      "447 3.801531420322135e-05\n",
      "448 3.7603087548632175e-05\n",
      "449 3.713938349392265e-05\n",
      "450 3.67984248441644e-05\n",
      "451 3.632652806118131e-05\n",
      "452 3.588247636798769e-05\n",
      "453 3.5508339351508766e-05\n",
      "454 3.510112583171576e-05\n",
      "455 3.467723945504986e-05\n",
      "456 3.4289238101337105e-05\n",
      "457 3.386099706403911e-05\n",
      "458 3.355701846885495e-05\n",
      "459 3.317090158816427e-05\n",
      "460 3.277704672655091e-05\n",
      "461 3.231363007216714e-05\n",
      "462 3.212285810150206e-05\n",
      "463 3.168695548083633e-05\n",
      "464 3.150834527332336e-05\n",
      "465 3.113338607363403e-05\n",
      "466 3.0756706109968945e-05\n",
      "467 3.0389064704650082e-05\n",
      "468 3.006316183018498e-05\n",
      "469 2.971780122607015e-05\n",
      "470 2.951604619738646e-05\n",
      "471 2.9183574952185154e-05\n",
      "472 2.87830553133972e-05\n",
      "473 2.8449936507968232e-05\n",
      "474 2.8168773496872745e-05\n",
      "475 2.780089016596321e-05\n",
      "476 2.7649279218167067e-05\n",
      "477 2.7509042411111295e-05\n",
      "478 2.7100619263364933e-05\n",
      "479 2.6996462111128494e-05\n",
      "480 2.681529258552473e-05\n",
      "481 2.6524121494730935e-05\n",
      "482 2.618109283503145e-05\n",
      "483 2.5847204597084783e-05\n",
      "484 2.5474595531704836e-05\n",
      "485 2.530452547944151e-05\n",
      "486 2.5091416318900883e-05\n",
      "487 2.486340599716641e-05\n",
      "488 2.469405808369629e-05\n",
      "489 2.433611371088773e-05\n",
      "490 2.4142180336639285e-05\n",
      "491 2.3962264094734564e-05\n",
      "492 2.372150993323885e-05\n",
      "493 2.3529368263552897e-05\n",
      "494 2.32418897212483e-05\n",
      "495 2.3048229195410386e-05\n",
      "496 2.2741187422070652e-05\n",
      "497 2.254541868751403e-05\n",
      "498 2.234030034742318e-05\n",
      "499 2.2062820789869875e-05\n"
     ]
    }
   ],
   "source": [
    "# 可运行代码见本文件夹中的 two_layer_net_custom_function.py\n",
    "import torch\n",
    "\n",
    "class MyReLU(torch.autograd.Function):\n",
    "    \"\"\"\n",
    "    我们可以通过建立torch.autograd的子类来实现我们自定义的autograd函数，\n",
    "    并完成张量的正向和反向传播。\n",
    "    \"\"\"\n",
    "    @staticmethod\n",
    "    def forward(ctx, x):\n",
    "        \"\"\"\n",
    "        在正向传播中，我们接收到一个上下文对象和一个包含输入的张量；\n",
    "        我们必须返回一个包含输出的张量，\n",
    "        并且我们可以使用上下文对象来缓存对象，以便在反向传播中使用。\n",
    "        \"\"\"\n",
    "        ctx.save_for_backward(x)\n",
    "        return x.clamp(min=0)\n",
    "\n",
    "    @staticmethod\n",
    "    def backward(ctx, grad_output):\n",
    "        \"\"\"\n",
    "        在反向传播中，我们接收到上下文对象和一个张量，\n",
    "        其包含了相对于正向传播过程中产生的输出的损失的梯度。\n",
    "        我们可以从上下文对象中检索缓存的数据，\n",
    "        并且必须计算并返回与正向传播的输入相关的损失的梯度。\n",
    "        \"\"\"\n",
    "        x, = ctx.saved_tensors\n",
    "        grad_x = grad_output.clone()\n",
    "        grad_x[x < 0] = 0\n",
    "        return grad_x\n",
    "\n",
    "\n",
    "device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\n",
    "\n",
    "# N是批大小； D_in 是输入维度；\n",
    "# H 是隐藏层维度； D_out 是输出维度\n",
    "N, D_in, H, D_out = 64, 1000, 100, 10\n",
    "\n",
    "# 产生输入和输出的随机张量\n",
    "x = torch.randn(N, D_in, device=device)\n",
    "y = torch.randn(N, D_out, device=device)\n",
    "\n",
    "# 产生随机权重的张量\n",
    "w1 = torch.randn(D_in, H, device=device, requires_grad=True)\n",
    "w2 = torch.randn(H, D_out, device=device, requires_grad=True)\n",
    "\n",
    "learning_rate = 1e-6\n",
    "for t in range(500):\n",
    "    # 正向传播：使用张量上的操作来计算输出值y；\n",
    "    # 我们通过调用 MyReLU.apply 函数来使用自定义的ReLU\n",
    "    y_pred = MyReLU.apply(x.mm(w1)).mm(w2)\n",
    "\n",
    "    # 计算并输出loss\n",
    "    loss = (y_pred - y).pow(2).sum()\n",
    "    print(t, loss.item())\n",
    "\n",
    "    # 使用autograd计算反向传播过程。\n",
    "    loss.backward()\n",
    "\n",
    "    with torch.no_grad():\n",
    "        # 用梯度下降更新权重\n",
    "        w1 -= learning_rate * w1.grad\n",
    "        w2 -= learning_rate * w2.grad\n",
    "\n",
    "        # 在反向传播之后手动清零梯度\n",
    "        w1.grad.zero_()\n",
    "        w2.grad.zero_()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (Spyder)",
   "language": "python3",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "227.797px"
   },
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
